package com.future;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;

public class Task {
	
	public void doSomeThing(){
		Callable<String> callable = new Callable<String>() {

			@Override
			public String call() throws Exception {
				System.out.println(System.currentTimeMillis());
				TimeUnit.SECONDS.sleep(2);
				System.out.println(System.currentTimeMillis());
				return "hello world";
			}
		};
	    ExecutorService service  = Executors.newFixedThreadPool(5);
	    Future<String> submit = service.submit(callable);
		try (OutputStream ops = new FileOutputStream(new File(""))) {

		} catch (Exception e) {
			// TODO: handle exception
		}
	    try {
	    	
			String string = submit.get();
			System.out.println(string);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ExecutionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
		
		
		
	}

}
